/*
 * Copyright 2012 Marsrutai.lt
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package lt.marsrutai.mobile.android.model;

import java.math.BigDecimal;
import java.util.List;

import android.os.Parcel;
import android.os.Parcelable;

public class Stop implements Parcelable {

    public static final Parcelable.Creator<Stop> CREATOR = new Parcelable.Creator<Stop>() {

        @Override
        public Stop createFromParcel(Parcel source) {
            return new Stop(source);
        }

        @Override
        public Stop[] newArray(int size) {
            return new Stop[size];
        }
    };
    
    private String id;
    private String name;
    private String fullName;
    private String directionName;

    private BigDecimal longitude;
    private BigDecimal latitude;

    private List<Schedule> schedules;

    public Stop() {
    }
    
    private Stop(Parcel in) {
        id = in.readString();
        name = in.readString();
        fullName = in.readString();
        directionName = in.readString();

        if (in.readInt() == 1) {
            longitude = new BigDecimal(in.readDouble());
        }
        if (in.readInt() == 1) {
            latitude = new BigDecimal(in.readDouble());
        }
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(id);
        dest.writeString(name);
        dest.writeString(fullName);
        dest.writeString(directionName);

        if (longitude == null) {
            dest.writeInt(0);
        }
        else {
            dest.writeInt(1);
            dest.writeDouble(longitude.doubleValue());
        }
        
        if (latitude == null) {
            dest.writeInt(0);
        }
        else {
            dest.writeInt(1);
            dest.writeDouble(latitude.doubleValue());
        }
    }
    
    @Override
    public int describeContents() {
        return 0;
    }
    
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getFullName() {
        return fullName;
    }

    public void setFullName(String fullName) {
        this.fullName = fullName;
    }

    public String getDirectionName() {
        return directionName;
    }

    public void setDirectionName(String directionName) {
        this.directionName = directionName;
    }

    public BigDecimal getLongitude() {
        return longitude;
    }

    public void setLongitude(BigDecimal longitude) {
        this.longitude = longitude;
    }

    public BigDecimal getLatitude() {
        return latitude;
    }

    public void setLatitude(BigDecimal latitude) {
        this.latitude = latitude;
    }

    public List<Schedule> getSchedules() {
        return schedules;
    }

    public void setSchedules(List<Schedule> schedules) {
        this.schedules = schedules;
    }

}
